<html>
<TMPL_INCLUDE name=./htmlheader.html>
<body>

<div style="border-bottom: 1px solid grey;margin-bottom:1em;">
<table width=100% border=0>
	<tr>
	<td class=pagetitle width="50%">Keep In Touch - Newsletter Tool for Unix Admins</td>
	<td rowspan="2" width="10%"><center><div id=header_status></div></center></td>
	<TD rowspan=2 width=10% style="border-right:1px solid lightgrey; text-align:right;">
	<form method=get name=DBTypeSelect>
		Test DB <input type=radio name=db_type id=db_type value=1 <TMPL_IF name=db_type_test>checked</TMPL_IF> onClick="document.DBTypeSelect.submit();">
		<p>
		Real DB <input type=radio name=db_type id=db_type value=2 <TMPL_IF name=db_type_real>checked</TMPL_IF> onClick="document.DBTypeSelect.submit();" > 
		<input type=hidden name=action value=changeDBType>
	</form>
	</TD>
	<td style='text-align: left; border-bottom: 0px solid grey;padding-left:1em;'> 
		<form method=post name=DBSelect action=<TMPL_VAR name=APP_PATH>/cgi-bin/admin/addr.cgi>
		<SELECT name=group_id id=group_id onChange="if (this.value == -1) {return false;} document.DBSelect.submit();" style="width:200px;">
			<OPTION value=-1>--Select Address Database--</OPTION>
			<TMPL_LOOP name=DATABASES>
				<OPTION value=<TMPL_VAR name=group_id>><TMPL_VAR name=group_id>. <TMPL_VAR name=group_name></OPTION>
			</TMPL_LOOP>
		</SELECT>
		<input type=hidden name=action value=changeDB>
		<input type=hidden name=db_type value=<TMPL_VAR name=db_type>>
		</form>
	</td>
	</tr>
	<tr>
	<td>
		<a class="selected" href=<TMPL_VAR name=APP_PATH>/cgi-bin/admin/Groups.pl>Groups &amp; Campaigns</a> | 
		<a href=<TMPL_VAR name=APP_PATH>/cgi-bin/admin/addr.cgi>Addresses</a> | 
		<!--<a href=#new>New List</a> | -->
		<a href=<TMPL_VAR name=APP_PATH>/cgi-bin/admin/newsletters.cgi>Content</a> |
		<a href=<TMPL_VAR name=APP_PATH>/cgi-bin/admin/Analytics.pl>Analytics</a> |
		<a onClick="CreateNewCampaign();">New Campaign</a> |
		<a href=<TMPL_VAR name=APP_PATH>/cgi-bin/admin/Settings.pl>Settings</a> |
		<a href="<TMPL_VAR name=APP_PATH>/cgi-bin/admin/Login.pl?action=quit">Logout</a>
		<br>
		<table border=0 cellpadding="0" cellspacing="0">
		<tr>
		<td>
			Database&nbsp;</td><TD style="border-left:1px lightgrey solid; font-weight:bold;">&nbsp;&nbsp;<TMPL_VAR name=group_name> (<TMPL_VAR name=db_type_desc>)
		</TD>
		</tr>
		</table>

	</td>
	<td style='text-align:left;padding-left:1em;' width=20%>  
	<!--<form method=get action="addr.cgi">-->
		<input id=search_str name=search_str onKeyPress="shortcut.add('ENTER', function() {GetSearchResults();});"><!--<br> <div style="height:5px;"></div>-->
		<!--<input type=submit name=action value=search>-->
		<!--<input type=button id=action value=search onClick="GetSearchResults();">-->
	<!--</form>-->
	</td>
	</tr>
</table>
</div>

<script>

// $('done_button').active = false;
shortcut.add('Escape', function () {$('search_str').focus();});

function CreateNewCampaign() {
    URL="Campaigns?action=create_new";
    // PARAMS="action=create&group_id=" + $('campaign_group_id').value + "&content_id=" + $('campaign_content_id').value;
    Modalbox.show(URL, {title:'Create New Campaign',width:'400'});
}

function SaveNewCampaign()
{
	URL="Campaigns";
	PARAMS	= "action=save_new&group_id=" + $('campaign_group_id').value + "&content_id=" + $('campaign_content_id').value + 
		  "&sender_email=" + $('sender_email').value + "&sender_name=" + $('sender_name').value + "&exit_link=" + $('exit_link').value;

	new Ajax.Updater ('result', URL, {method: 'get', parameters: PARAMS, onSuccess: ReleaseDone,});
}

function ReleaseDone()
{
	$('done_button').active = true;
}

function PrintStatus(element, message)
{
	// Thanks to ajaxload.info for the cool ajax loader gif.
	// See also http://www.sanbaldo.com/wordpress/1/ajax_gif/
// 	$(element).innerHTML = "<img src=<TMPL_VAR name=APP_PATH>/images/ajax-loader.gif alt='Loading...'>";
	$(element).innerHTML = message;
}

function GetSearchResults()
{
	URL	="addr.cgi";
	PARAMS	= "action=search&search_str=" + $('search_str').value;
// alert(PARAMS);
	new Ajax.Updater ('addr_list', 
			  URL, 
			  {
			  	parameters: PARAMS, 
			  	asynchronous: true,
			  	onLoading: PrintStatus('header_status', "Loading search results..."),
			  	onComplete: ClearStatus,
			  });
	$('search_str').focus();
	$('search_str').select();
}

function SetDBType()
{
	URL	="addr.cgi";
	PARAMS	= "action=SetDBType&db_type" + $('db_type').value;
// alert(PARAMS);
	new Ajax.Updater ('addr_list', URL, {
	                           parameters: PARAMS, 
	                           onLoading: PrintStatus('addr_list', "<div style='height:400px;'>Loading search results...</div>"),
	                           });
}

function ClearStatus()
{
	$('header_status').innerHTML = '';
}

</script>